package com.chainyoung.component_tmmarket.mvp.presenter;

import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.di.scope.FragmentScope;
import com.chainyoung.common.http.websocket.WebSoketUtils;
import com.chainyoung.common.http.websocket.WsManager;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmmarket.bean.Kline;
import com.chainyoung.component_tmmarket.bean.MarketList;
import com.chainyoung.component_tmmarket.mvp.contract.MarketListContract;
import com.chainyoung.component_tmmarket.mvp.contract.MarketMainContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;


public class MarketListPresenter extends BasePresenter<MarketListContract.Model, MarketListContract.View> {


    @Inject
    public MarketListPresenter(MarketListContract.Model model, MarketListContract.View view) {
        super(model, view);
    }


    public void getMarketList(TreeMap<String, Object> map) {
        addSubscribe(
                mModel.getMarketList(map)
                        .compose(RxUtils.<String>rxSchedulerHelper())
                        .subscribeWith(new CommonSubscriber<String>(mView) {
                            @Override
                            public void onNext(String data) {
                                mView.showMarketList(data);
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
                            }
                        })
        );
    }


}
